<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Import BLOB/CLOB data from a file</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.cubrid-lob2-import" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">cubrid_lob2_import</h1>
  <p class="verinfo">(PECL CUBRID &gt;= 8.4.1)</p><p class="refpurpose"><span class="refname">cubrid_lob2_import</span> &mdash; <span class="dc-title">Import BLOB/CLOB data from a file</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.cubrid-lob2-import-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>cubrid_lob2_import</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$lob_identifier</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$file_name</code></span>
   ) : <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   The <span class="function"><strong>cubrid_lob2_import()</strong></span> function is used to save the
   contents of BLOB/CLOB data from a file. To use this function, you must use
   <span class="function"><a href="cubrid_lob2_new.html" class="function">cubrid_lob2_new()</a></span> or fetch a lob object from CUBRID database
   first. If the file already exists, the operation will fail. 
   This function will not influence the cursor position of the lob object. 
   It operates the entire lob object.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.cubrid-lob2-import-parameters">
 <h3 class="title">参数</h3>
 <p class="para">
  <dl>

   
    <dt>
<code class="parameter">lob_identifier</code></dt>

    <dd>

     <p class="para">Lob identifier as a result of <span class="function"><a href="cubrid_lob2_new.html" class="function">cubrid_lob2_new()</a></span> or get from the result set.</p>
    </dd>

   
   
    <dt>
<code class="parameter">filename</code></dt>

    <dd>

     <p class="para">File name you want to import BLOB/CLOB data. It also supports the path of the file.</p>
    </dd>

   
  </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.cubrid-lob2-import-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
    <strong><code>TRUE</code></strong> if the process is successful and <strong><code>FALSE</code></strong> for failure.
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.cubrid-lob2-import-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-1126">
   <p><strong>Example #1 <span class="function"><a href="cubrid_lob2_export.html" class="function">cubrid_lob2_export()</a></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$conn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">33000</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"demodb"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"dba"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">cubrid_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,</span><span style="color: #DD0000">"DROP&nbsp;TABLE&nbsp;if&nbsp;exists&nbsp;test_lob"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">cubrid_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,</span><span style="color: #DD0000">"CREATE&nbsp;TABLE&nbsp;test_lob&nbsp;(id&nbsp;INT,&nbsp;contents&nbsp;CLOB)"</span><span style="color: #007700">);<br />&nbsp;<br /></span><span style="color: #0000BB">$req&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_prepare</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"INSERT&nbsp;INTO&nbsp;test_lob&nbsp;VALUES&nbsp;(?,&nbsp;?)"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">cubrid_bind</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$lob&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_lob2_new</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"clob"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">cubrid_lob2_import</span><span style="color: #007700">(</span><span style="color: #0000BB">$lob</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"doc_1.txt"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">cubrid_lob2_bind</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$lob</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'CLOB'</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;or&nbsp;cubrid_lob2_bind($req,&nbsp;2,&nbsp;$lob);<br /><br /></span><span style="color: #0000BB">cubrid_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">cubrid_lob2_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$lob</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">cubrid_disconnect</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.cubrid-lob2-import-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
   <li class="member"><span class="function"><a href="cubrid_lob2_new.html" class="function" rel="rdfs-seeAlso">cubrid_lob2_new()</a> - Create a lob object</span></li>
   <li class="member"><span class="function"><a href="cubrid_lob2_close.html" class="function" rel="rdfs-seeAlso">cubrid_lob2_close()</a> - Close LOB object</span></li>
   <li class="member"><span class="function"><a href="cubrid_lob2_export.html" class="function" rel="rdfs-seeAlso">cubrid_lob2_export()</a> - Export the lob object to a file</span></li>
   <li class="member"><span class="function"><a href="cubrid_lob2_bind.html" class="function" rel="rdfs-seeAlso">cubrid_lob2_bind()</a> - Bind a lob object or a string as a lob object to a prepared statement as parameters</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>